home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Games / Starter / JST / Developer / sources / src / loaders / Prince / rippopdisk.c < prev   
Encoding:
C/C++ Source or Header  |  1999-12-03  |  1.1 KB  |  47 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos/dos.h>
  4. #include <proto/dos.h>
  5. #include <proto/exec.h>
  6. #include <pragmas/dos_pragmas.h>
  7.  
  8. #include <exec/types.h>
  9. #include <exec/memory.h>
  10.  
  11. extern ULONG ReadPOPSectors(char *,ULONG,ULONG);
  12.  
  13. #define Erreur() {printf("** Something went wrong !!\n");exit(1);}
  14. #define NB_SECTORS 0x53
  15. #define DISK_SIZE 0x1800*NB_SECTORS
  16.  
  17. main(unsigned int argc,char **argv)
  18.  
  19. {
  20. char *buffer;
  21. FILE *f;
  22.  
  23. if (argc==0) exit(0);
  24.  
  25. printf("Prince of Persia (shitty) disk reader (but the only one)\nCoded by JF Fabre © 1997\n");
  26. if (argc<2) {printf("** Usage readpop <filename>\n");exit(0);}
  27.  
  28. buffer=(char *)AllocMem(DISK_SIZE,MEMF_CLEAR);
  29.  
  30. if (!buffer) {printf("** Unable to allocate memory\n");exit(1);}
  31.  
  32. printf("Reading disk. Please wait...\n");
  33. if (ReadPOPSectors(buffer,0x1,NB_SECTORS)!=0) Erreur();
  34. printf("Disk read\n");
  35.  
  36. if (!(f=fopen(argv[1],"wb"))) {FreeMem((APTR)buffer,DISK_SIZE);printf("** Unable to open destination file\n");exit(1);}
  37.  
  38. printf("Writing disk image...");fflush(stdout);
  39. fwrite(buffer,DISK_SIZE,1,f);
  40. printf("Done.\n");
  41.  
  42. fclose(f);
  43.  
  44. FreeMem((APTR)buffer,DISK_SIZE);
  45.  
  46. }
  47.